package com.lyx.bank.service.impl;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lyx.bank.entity.TransactionRecord;
import com.lyx.bank.mapper.RecordsMapper;
import com.lyx.bank.service.RecordsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;


/**
 * @ClassName RecordsServiceImpl
 * @Description: TODO
 * @Author 86152
 * @Date 2022/4/24
 * @Version V1.0
 **/


@Service
public class RecordsServiceImpl extends ServiceImpl<RecordsMapper, TransactionRecord> implements RecordsService {

    @Autowired
    private RabbitTemplate rabbitTemplate;


    @Override
    public Page<TransactionRecord> getRecord(Page<TransactionRecord> page, String cardNo, String oneDate, String towDate) {
        List<TransactionRecord> userList = this.baseMapper.getRecord(page, cardNo,oneDate,towDate);
        page.setRecords(userList);
        return page;
    }

    @Override
    public void createdRecords(Map<String,Object> map){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String cardNo =(String) map.get("cardNo");
        String format = sdf.format(new Date());
        Date data = java.sql.Date.valueOf(format);
        Date transactionDate =data;
        Double amout = (Double) map.get("amout");
        Double balance = (Double) map.get("balance");
        String transactionType =(String) map.get("transactionType");
        String remark =(String) map.get("remark");
        this.baseMapper.createdRecords(cardNo,transactionDate,amout,balance,transactionType,remark);
    }

    public void createdRecords2(Map<String,Object> map){
        System.out.println(map);
        System.out.println("--------------------111111111111111111111111111111111-------------------------------");
    }



}
